package com.day17;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义泛型类
 *
 * @param <T>
 */
public class Order<T> {

    String orderName;

    int orderId;

    //类的内部结构，可以使用类的泛型。

    T orderT;

    public Order() {
    }

    public Order(String orderName, int orderId, T orderT) {
        this.orderName = orderName;
        this.orderId = orderId;
        this.orderT = orderT;
    }

    public T getOrderT() {
        return orderT;
    }

    public void setOrderT(T orderT) {
        this.orderT = orderT;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderName='" + orderName + '\'' +
                ", orederId=" + orderId +
                ", orderT=" + orderT +
                '}';
    }

    //泛型方法
    //泛型方法
    public <E> List<E> coprFormArrayToList(E[] arr) {
        ArrayList<E> list = new ArrayList<>();

        for (E e : arr) {
            list.add(e);
        }

        return list;

    }
}
